package elm.controller;

import elm.dao.FoodDao;
import elm.entity.po.Food;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/food")
public class FoodController {
    @Resource
    FoodDao foodDao;
    @GetMapping("/getFoods")
    public Iterable<Food> getFoods() {
        return foodDao.findAll();
    }

    @PostMapping("/addFood")
    public Food addFood(Food food) {
        return foodDao.save(food);
    }
}
